package cn.edu.cug.cs.gtl.docsrv;

import cn.edu.cug.cs.gtl.docsrv.config.Configuration;
import cn.edu.cug.cs.gtl.docsrv.config.FTPConfig;
import cn.edu.cug.cs.gtl.docsrv.config.HDFSConfig;
import cn.edu.cug.cs.gtl.docsrv.config.ManagerConfig;
import cn.edu.cug.cs.gtl.extractor.ShapeExtractor;
import cn.edu.cug.cs.gtl.mybatis.BatisWrapper;
import cn.edu.cug.cs.gtl.mybatis.mapper.shp.ShpAll;
import org.opengis.feature.simple.SimpleFeature;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import java.io.File;
import java.io.FileInputStream;
import java.util.List;

@SpringBootApplication
public class DocsrvApplication {
    static Logger logger =LoggerFactory.getLogger(DocsrvApplication.class);
    @Autowired
    FTPConfig ftpConfig;
    @Autowired
    HDFSConfig hdfsConfig;
    @Autowired
    ManagerConfig managerConfig;

    public static void main(String[] args) {

        String resource ="";
        logger.debug(String.valueOf(args.length));
        for(String s: args){
            logger.debug(s);
            if(s.contains("mybatis-config.xml")){
                resource=s;
            }
        }
        resource = "oracle-mybatis-config.xml";
        BatisWrapper.initializeWrapper(resource);
        SpringApplication.run(DocsrvApplication.class, args);
    }

    @PostConstruct
    public void initialize(){
        Configuration.setFtpConfig(ftpConfig);
        Configuration.setHdfsConfig(hdfsConfig);
        Configuration.setManagerConfig(managerConfig);
    }

    @PreDestroy
    public void destroy(){

    }
}
